package edu.scut.autoProcessor.po;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class JobPo {
	
	private static final Log logger = LogFactory.getLog(JobPo.class);
	
	private static final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	private int id;
	
	private String hostIP;
	
	private String hostName;
	
	private String type;
	
	private String result;
	
	private Date beginTime;
	
	private Date endTime;
	
	public JobPo(){}
	
	public JobPo(String host_ip, String host_name, String type, String result, Date begin_time, Date end_time){
		this.hostIP = host_ip;
		this.hostName = host_name;
		this.type = type;
		this.result = result;
		this.beginTime = begin_time;
		this.endTime = end_time;
	}
	
	public void setId(int id){
		this.id = id;
	}
	
	public void setHostIP(String host_ip){
		this.hostIP = host_ip;
	}
	
	public void setHostName(String host_name){
		this.hostName = host_name;
	}
	
	public void setType(String type){
		this.type = type;
	}
	
	public void setResult(String result){
		this.result = result;
	}
	
	public void setBeginTime(Date begin_time){
		this.beginTime = begin_time;
	}
	
	public void setEndTime(Date end_time){
		this.endTime = end_time;
	}
	
	public int getId(){
		return id;
	}
	
	public String getType(){
		return type;
	}
	
	public String getHostIP(){
		return hostIP;
	}
	
	public String getHostName(){
		return hostName;
	}
	
	public String getResult(){
		return result;
	}
	
	public String getBeginTime(){
		try{
			return format.format(beginTime);
		}catch(Exception e){
			logger.error(e.getMessage());
			return null;
		}
	}
	
	public String getEndTime(){
		if(endTime == null){
			return null;
		}else{
			
			try{
				return format.format(endTime);
			}catch(Exception e){
				logger.error(e.getMessage());
				return null;
			}
			
		}
	}
}
